package javacode.chapter05.exer;

import java.util.Scanner;

public class Exercise01 {
    public static void main(String[] args) {
        // 输入10个会员的积分，并采用冒泡排序法进行排序

        // 1.通过终端输入10个会员的积分
        int[] scores = new int[10];
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入10个会员的积分：");
        for (int i = 0; i < 10; i++) {
            scores[i] = scanner.nextInt();
        }
        // 2.冒泡排序
        for (int i = 0; i < scores.length - 1; i++) {
            for (int j = 0; j < scores.length - 1 - i; j++) {
                if (scores[j] > scores[j + 1]) {
                    int temp = scores[j];
                    scores[j] = scores[j + 1];
                    scores[j + 1] = temp;
                }
            }
        }

        // 3.对排序后的数组元素进行遍历输出
        for (int i = 0; i < scores.length; i++) {
            System.out.print(scores[i] + " ");
        }
    }
}
